#pragma once

namespace GraphCutLib
{
	struct Vector2D 
	{
		Vector2D()
		{
			x = y = 0.0f;
		}

		Vector2D	operator - (const Vector2D& p) const
		{
			return Vector2D(x - p.x,y - p.y);
		}

		Vector2D(float xx,float yy)
		{
			x = xx;
			y = yy;
		}
		float x;
		float y;
	};

	void	normalizeVec2D(Vector2D& vec)
	{
		const float t = sqrtf(vec.x * vec.x + vec.y * vec.y);
		vec.x /= t;
		vec.y /= t;
	}

	float	dotVec2D(const Vector2D& vec1,const Vector2D& vec2)
	{
		return vec1.x * vec2.x + vec1.y * vec2.y;
	}

	float   distance2D(const Vector2D& p0,const Vector2D& p1)
	{
		const Vector2D vec = p1 - p0;
		return sqrtf(vec.x * vec.x + vec.y * vec.y);
	}
}